﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        private Game game;
        public Form1()
        {
            InitializeComponent();
        }

        private void gameArea_Load(object sender, EventArgs e)
        {
            //初始化
            game = new Game();
        }

        private void gameArea_Paint(object sender, PaintEventArgs e)
        {
            if(game!=null)
            {
                game.Draw(e.Graphics, this.gameArea1.Size);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if(game!=null)
            {
                //按键传给game
                game.KeyDown(e.KeyCode.ToString());
                gameArea1.Invalidate();
            }
        }
    }
}
